var Bearcat = require('bearcat');
var beanPath = require.resolve('../beanConfig.json');

var beanFactory = new Object();

beanFactory.init = function(next) {
    console.log("init method start.........");
    console.log(beanPath);

    var bearcat = Bearcat.createApp([beanPath]);

    bearcat.start(function() {
        beanFactory.bearcat = bearcat;

        if(next){
            next();
        }
    });
}

beanFactory.getBean = function(id) {
    var bearcat = beanFactory.bearcat;

    if(bearcat) {
        return bearcat.getBean(id);
    }
}

module.exports = beanFactory;
